package bridge

import (
	"gitee.com/tomatomeatman/golang-repository/bricks3/function/configutil"
	"gitee.com/tomatomeatman/golang-repository/bricks3/utils/ginutil"
	"github.com/gin-gonic/gin"
)

/**
 * 桥接代理请求控制器
 */
type BridgeController struct {
}

/**
 * 初始化
 */
func init() {
	if configutil.HasSection("./config/app.ini", "CloudCenter") { //禁用桥接
		return
	}

	//-- 接口注册 --//
	ginutil.AddUrl("/proxy/*proxy", BridgeController{}.ProxyGet, ginutil.GET)
	ginutil.AddUrl("/proxy/*proxy", BridgeController{}.ProxyPost, ginutil.POST)
}

func (control BridgeController) ProxyGet(ctx *gin.Context) (bool, string, interface{}) {
	return BridgeDao{}.ProxyGet(ctx)
}

func (control BridgeController) ProxyPost(ctx *gin.Context) (bool, string, interface{}) {
	return BridgeDao{}.ProxyPost(ctx)
}
